#include "Callback.h"
#include <stdlib.h>
#include <string.h>

Callback::Callback(void)
{
}

Callback::Callback(CallBackType cbtype, const wchar_t* data)
{
	wchar_t* wstr = (wchar_t*)malloc(sizeof(char) * wcslen(data) + 1);
	wcscpy(wstr, data);
	wcscat(wstr, L"\0");

	char* cstr = (char*)malloc(sizeof(char) * MB_CUR_MAX);
	wcstombs(cstr, data, wcslen(wstr)); 

	this->raw = (char*)malloc(sizeof(char) * wcslen(data) + 12);
	switch(cbtype)
	{
	case DISCOVER_OBJECT_INSTANCE:
		strcpy(this->raw, "discover::\0");
		break;
	case REFLECT_ATTRIBUTE_VALUES:
		strcpy(this->raw, "reflect ::\0");
		break;
	default:
		break;
	}
	strcat(this->raw, cstr);
}

Callback::~Callback(void)
{
}

char* Callback::serialize()
{
	return this->raw;
}
